#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

// 计算最大公约数
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

// 分数相乘并化简
pair<ll, ll> multiply(ll a, ll b, ll c, ll d) {
    ll num = a * c;
    ll den = b * d;
    ll g = gcd(num, den);
    return {num / g, den / g};
}

// 比较两个分数大小
bool lessThan(ll a, ll b, ll c, ll d) {
    return a * d < c * b;
}

bool inRange(ll x_num, ll x_den, ll A, ll B, ll C, ll D) {
    if (lessThan(x_num, x_den, A, B)) return false;
    if (lessThan(C, D, x_num, x_den)) return false;
    return true;
}

void solve() {
    ll K, N, A, B, C, D;
    cin >> K >> N >> A >> B >> C >> D;
    
    // 计算K*C/(N*D)的整数部分，确定m的上限
    ll max_m = (K * C) / (N * D);
    // 确保m有合理范围
    max_m = min(max_m, K * 2);
    
    ll best_num = 0, best_den = 1;
    
    // 遍历可能的m值
    for (ll m = 0; m <= max_m; ++m) {
        // 计算x的下界和上界（分数形式）
        ll lower_num, lower_den, upper_num, upper_den;
        
        if (m == 0) {
            // 特殊情况：m=0时，x > K/N
            lower_num = K;
            lower_den = N;
            upper_num = 1e18;  // 一个很大的数表示正无穷
            upper_den = 1;
        } else {
            // 一般情况：K/[N(m+1)] < x <= K/[N*m]
            lower_num = K;
            lower_den = N * (m + 1);
            upper_num = K;
            upper_den = N * m;
        }
        
        // 与[L, R]取交集，得到候选x的范围
        ll cand_l_num, cand_l_den, cand_r_num, cand_r_den;
        
        // 左边界取最大值
        if (lessThan(A, B, lower_num, lower_den)) {
            cand_l_num = lower_num;
            cand_l_den = lower_den;
        } else {
            cand_l_num = A;
            cand_l_den = B;
        }
        
        // 右边界取最小值
        if (lessThan(upper_num, upper_den, C, D)) {
            cand_r_num = upper_num;
            cand_r_den = upper_den;
        } else {
            cand_r_num = C;
            cand_r_den = D;
        }
        
        // 如果候选区间无效，跳过
        if (lessThan(cand_r_num, cand_r_den, cand_l_num, cand_l_den)) {
            continue;
        }
        
        // 计算该区间内的最优x值：尽可能靠近右边界
        ll x_num, x_den;
        
        // 优先选择区间右边界
        if (inRange(cand_r_num, cand_r_den, A, B, C, D)) {
            x_num = cand_r_num;
            x_den = cand_r_den;
        } else {
            // 否则选择区间左边界
            x_num = cand_l_num;
            x_den = cand_l_den;
        }
        
        // 计算当前x对应的函数值
        auto [curr_num, curr_den] = multiply(x_num, x_den, m + 1, 1);
        
        // 更新最优解
        if (lessThan(best_num, best_den, curr_num, curr_den)) {
            best_num = curr_num;
            best_den = curr_den;
        }
    }
    
    cout << best_num << "/" << best_den << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
    
    return 0;
}
